/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Implementation.SourceCode.GUI;

import Implementation.SourceCode.Utilities.HibernateUtil;
import Implementation.SourceCode.entities.Material;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author mrkingdom75
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
//        UIMain main = new UIMain();
//        main.setTitle("Báo Cáo Chi - © mrkingdom75@gmail.com");
//        main.setVisible(true);
        try {
            Material mar = new Material();
            mar.setName("thịt heo");
            mar.setShortName("thit heo");
            mar.setCode("th");

            Session session = HibernateUtil.getSessionFactory().openSession();
            Transaction tx = session.beginTransaction();
            
            List<Material> lstMarterial = session.createQuery("from Material").list();
            for(Material mar1 : lstMarterial){
                System.out.println("name : "+mar1.getId());
            }
//            session.save(mar);
            
            tx.commit();
            session.close();
            
            HibernateUtil.shutdown();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}
